<?php

namespace app\appletsapi\validate;

use think\Validate;

class Place extends Validate
{
    protected $scene = [
        'place' => ['cart_ids','receive_name','r_address','r_phone','receive_time'],
        'edit' => ['order_id','receive_name','r_address','r_phone','receive_time'],
    ];

    protected $rule =   [
        'cart_ids' => 'require',
        'order_id' => 'require',
        'receive_name' => 'require',
        'r_address' => 'require',
        'r_phone' => 'require|mobile',
        'receive_time' => 'require',
//        'nsort' => 'checkType',
    ];

    protected $message  =   [
        'cart_ids.require' => '至少选择一件商品下单',
        'order_id.require' => '缺少订单id',
        'receive_name.require' => '请填写下单人姓名',
        'r_phone.require' => '请填写联系电话',
        'r_phone.mobile' => '联系电话格式错误',
        'r_address.require' => '请填写配送地址',
        'receive_time.require' => '请选择配送时间',
//        'nsort.checkType' => '排序类型错误2',
    ];

//    protected function checkType($value)
//    {
//        $arr = ['desc','asc'];
//        return in_array($value,$arr) == true ? true : '排序类型错误';
//    }
}
